<template>
  <el-row>
    <el-col :span="5">
      <basic-container>
        <avue-tree :option="treeOption" :data="treeData"
                   @node-click="nodeClick" :loading="treeLoading"
                   :key="key"/>
      </basic-container>
    </el-col>
    <el-col :span="19">
      <basic-container>
        <avue-crud :option="option"
                   :table-loading="loading"
                   :data="data"
                   :page.sync="page"
                   v-model="form"
                   ref="crud"
                   @search-change="searchChange"
                   @search-reset="searchReset"
                   @current-change="currentChange"
                   @size-change="sizeChange"
                   @refresh-change="refreshChange">
          <template slot-scope="{row}" slot="menu">
            <el-button type="text"
                       size="small"
                       plain
                       icon="el-icon-view"
                       class="none-border"
                       @click.stop="view(row)">查 看
            </el-button>
          </template>
          <template slot-scope="{disabled,size}" slot="current_cycleSearch">
            <div v-if="query.statistical_type=='year'">
              <el-date-picker
                v-model="query.current_cycle"
                type="year"
                value-format="yyyy-MM-dd"
                placeholder="选择年">
              </el-date-picker>
            </div>
            <div v-if="query.statistical_type=='month'">
              <el-date-picker
                v-model="query.current_cycle"
                type="month"
                value-format="yyyy-MM-dd"
                placeholder="选择月">
              </el-date-picker>
            </div>
            <div v-if="query.statistical_type=='date'">
              <el-date-picker
                v-model="query.current_cycle"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </div>
            <div v-if="query.statistical_type=='quarter'">
              <jdSelect @getValue="changeCycle" ref="jd"></jdSelect>
            </div>
          </template>
        </avue-crud>
      </basic-container>
    </el-col>
    <div v-if="tjDetail">
      <el-dialog title="查 看"
                 append-to-body
                 :visible.sync="tjDetail" width="70%" :before-close="viewClose">
        <span><h3 style="color:#2693fa"><i class="el-icon-view"></i> 规则详情</h3></span>


        <avue-form ref="Null_v"
                   v-model="ruleForm"
                   :option="Null_VIEW"
                   v-if="ruleForm.type=='Null'"
                   :key="infoKey">
        </avue-form>
        <avue-form ref="RANGE_v"
                   v-model="ruleForm"
                   :option="RANGE"
                   v-if="ruleForm.type=='RANGE'"
                   :key="infoKey"
        >
          <template slot="valueRange" slot-scope="scope">
            <el-row>
              <el-col :span="11">
                <el-input size="small" placeholder="请输入最小值" v-model="ruleForm.minValue"
                          show-word-limit disabled>
                </el-input>
              </el-col>
              <el-col :span="2" style="text-align: center;color: #606266">
                —
              </el-col>
              <el-col :span="11">
                <el-input size="small" placeholder="请输入最大值" v-model="ruleForm.maxValue"
                          show-word-limit disabled>
                </el-input>
              </el-col>
            </el-row>
          </template>
        </avue-form>
        <avue-form ref="LOGIC_v"
                   v-model="ruleForm"
                   :option="LOGIC_VIEW"
                   v-if="ruleForm.type=='LOGIC'"
                   :key="infoKey">
        </avue-form>
        <avue-form ref="REPEAT_v"
                   v-model="ruleForm"
                   :option="REPEAT"
                   v-if="ruleForm.type=='REPEAT'" :key="infoKey">
        </avue-form>
        <avue-form ref="TIMELY_v"
                   v-model="ruleForm"
                   :option="TIMELY"
                   v-if="ruleForm.type=='TIMELY'" :key="infoKey">
        </avue-form>
        <avue-form ref="STANDARD_v"
                   v-model="ruleForm"
                   :option="STANDARD"
                   v-if="ruleForm.type=='STANDARD'" :key="infoKey">
          <template slot="specificationType" slot-scope="scope">
            <el-select v-model="ruleForm.specificationType" placeholder="请选择 规范类型">
              <el-option v-for="item in specificationTypeDic"
                         :key="item.dictKey"
                         :label="item.dictValue"
                         :value="item.dictKey"></el-option>
            </el-select>
          </template>
          <template slot="lengthRange" slot-scope="scope">
            <el-row>
              <el-col :span="11">
                <el-input-number v-model="ruleForm.minLength" label="请输入最小值" size="small" style="width: 100%"
                                 :precision="0"
                                 :max="ruleForm.maxLength" :min="0"></el-input-number>
              </el-col>
              <el-col :span="2" style="text-align: center;color: #606266">
                —
              </el-col>
              <el-col :span="11">
                <el-input-number v-model="ruleForm.maxLength" label="请输入最大值" size="small" style="width: 100%"
                                 :precision="0"
                                 :min="ruleForm.minLength"></el-input-number>
              </el-col>
            </el-row>
          </template>
          <template slot="contain" slot-scope="scope">
            <el-row>
              <el-col :span="14">
                <el-input size="small" placeholder="请输入字符串内容" v-model="ruleForm.containString"
                          show-word-limit>
                </el-input>
              </el-col>
              <el-col :span="6">
                <el-select v-model="ruleForm.charPosition" placeholder="请选择 字符串位置"
                           @change="delete ruleForm.specificPosition">
                  <el-option v-for="item in charPositionDic"
                             :key="item.value"
                             :label="item.label"
                             :value="item.value"></el-option>
                </el-select>
              </el-col>
              <el-col :span="4">
                <div v-if="ruleForm.charPosition=='specific'">
                  <el-input-number v-model="ruleForm.specificPosition" label="请输入指定位置" size="small" style="width: 100%"
                                   :precision="0" :controls="false"
                                   :min="0"></el-input-number>
                </div>
              </el-col>
            </el-row>
          </template>
          <template slot="regex" slot-scope="scope">
            <el-input size="small" placeholder="请填写正则表达式" v-model="ruleForm.regex"
                      show-word-limit>
            </el-input>
          </template>
        </avue-form>
        <avue-form ref="QUOTE_v"
                   v-model="ruleForm"
                   :option="QUOTE"
                   v-if="ruleForm.type=='QUOTE'" :key="infoKey">
          <template slot="referenceMode" slot-scope="scope">
            <el-select v-model="ruleForm.referenceMode" placeholder="请选择 引用方式">
              <el-option label="字典值" value='1'></el-option>
              <el-option label="表字段" value='2'></el-option>
            </el-select>
          </template>
          <template slot="tableField" slot-scope="scope">
            <el-input size="small" v-model="ruleForm.tableField"></el-input>
          </template>
        </avue-form>


        <span><h3 style="color:#2693fa"><i class="el-icon-view"></i> 错误数据</h3></span>
        <avue-crud :option="jlOption"
                   :table-loading="jlLoading"
                   :data="jlData"
                   :page.sync="jlPage"
                   v-model="jlForm"
                   ref="jlCrud"
                   @current-change="jlCurrentChange"
                   @size-change="jlSizeChange"
                   @on-load="jlOnLoad">
          <template slot-scope="scope" slot="menu">
            <el-button size="small" type="text" icon="el-icon-setting" v-if="scope.row.if_exception=='0'"
                       @click.stop="setAsException(scope.row)">设为例外
            </el-button>
          </template>
        </avue-crud>
        <div slot="footer" class="dialog-footer"></div>
      </el-dialog>
    </div>
  </el-row>
</template>

<script>
import {getModelThemeTree, getStatisticalType} from "@/api/data_quality/business_model";
import {getTJPageList, getJLPageList, setAsException} from "@/api/data_quality/quality_testing_programme";
import {validatenull} from "@/util/validate";
import jdSelect from "@/views/data_quality/quality_testing_programme/result_statistics/jdSelect"
import {getRuleDetail} from "@/api/data_quality/manage_rule"
import {getDictionary} from '@/api/system/dictbiz'

export default {
  name: "index",
  components: {jdSelect},
  data() {
    return {
      jlLoading: true,
      jlData: [],
      jlPage: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      jlForm: {},
      jlQuery: {},
      treeLoading: true,
      treeData: [],
      treeOption: {
        addBtn: false,
        menu: false,
        size: 'small',
        props: {
          label: 'title',
          value: 'id',
          children: 'children'
        }
      },
      key: 0,
      form: {},
      query: {
        current_cycle: '',
        statistical_type: '',
      },
      loading: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      option: {
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        header: false,
        searchBtn: false,
        column: [
          {
            label: "统计类型",
            prop: "current_cycle",
            hide: true,
            searchslot: true,
            search: true,
          },
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "规则描述",
            prop: "describe",
          },
          {
            label: "错误合计",
            prop: "total_error",
          },
          {
            label: "例外合计",
            prop: "total_exception",
          },
          {
            label: "已修复合计",
            prop: "total_repaired",
          },
        ]
      },
      data: [],
      statisticalType: '',
      model_id: '',
      tjDetail: false,
      jlOption: {
        addBtn: false,
        editBtn: false,
        delBtn: false,
        index: true,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        border: true,
        header: false,
        viewBtn: true,
        indexLabel: '序号',
        labelWidth: 130,
        column: [
          {
            label: "数据表主键字段",
            prop: "key_column",
          },
          {
            label: "数据表主键说明",
            prop: "key_comment",
          },
          {
            label: "数据表主键值",
            prop: "key_value",
            span: 24,
          },
          {
            label: "检查字段",
            prop: "check_column",
            hide: false,
          },
          {
            label: "检查字段值",
            prop: "check_column_value",
            hide: false,
          },
        ]
      },
      ruleForm: {},
      infoKey: 0,
      Null_VIEW: {
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        detail: true,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "联合不为空",
            prop: "unionNotNull",
            dicData: [
              {
                label: '是',
                value: '1'
              },
              {
                label: '否',
                value: '0'
              }
            ],
            type: 'radio',
            props: {
              label: 'label',
              value: 'value'
            },
          },
          {
            label: "检查字段",
            prop: "checkField",
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      RANGE: {
        detail: true,
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "检查字段",
            prop: "checkField",
          },
          {
            label: "取值范围",
            prop: "valueRange",
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      LOGIC_VIEW: {
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        detail: true,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "关联关系",
            prop: "relations",
            type: 'dynamic',
            span: 24,
            children: {
              viewBtn: true,
              column: [
                {
                  label: "主题表",
                  prop: "joinTableName",
                },
                {
                  label: "连接方式",
                  prop: "joinType",
                  type: 'select',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=join_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                },
                {
                  label: "连接字段（主题表）",
                  prop: "themeJoinFieldName",
                },
                {
                  label: "连接字段（检查表）",
                  prop: "checkJoinField",
                },
              ]
            }
          },
          {
            label: "检查公式",
            prop: "checkFormula",
            span: 24,
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      REPEAT: {
        detail: true,
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "组合重复",
            prop: "combineRepeat",
            dicData: [
              {
                label: '是',
                value: '1'
              }
            ],
            type: 'radio',
            props: {
              label: 'label',
              value: 'value'
            },
            value: '0'
          },
          {
            label: "检查字段",
            prop: "checkField",
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      TIMELY: {
        detail: true,
        enter: false,
        calcHeight: 30,
        labelWidth: 140,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "检查字段",
            prop: "checkField",
          },
          {
            label: "允许误差最大天数",
            prop: "maxAllowableErrorDays",
            type: 'number',
            precision: 0,
            minRows: 0,
            value: 0,
          },
          {
            label: "检查公式",
            prop: "checkFormula",
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      STANDARD: {
        detail: true,
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "检查字段",
            prop: "checkField",
          },
          {
            label: "规范类型",
            prop: "specificationType",
            formslot: true,
          },
          {
            label: "规范子类型",
            prop: "specificationSubtype",
            display: false,
            type: 'select',
            dicData: [],
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "长度范围",
            prop: "lengthRange",
            display: false,
          },
          {
            label: "字符串内容",
            prop: "contain",
            display: false,
          },
          {
            label: "正则表达式",
            prop: "regex",
            display: false,
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      QUOTE: {
        enter: false,
        calcHeight: 30,
        labelWidth: 110,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        selection: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        saveBtn: false,
        cancelBtn: false,
        dialogClickModal: false,
        columnBtn: false,
        refreshBtn: false,
        searchShowBtn: false,
        submitBtn: false,
        emptyBtn: false,
        detail: true,
        column: [
          {
            label: "规则代码",
            prop: "code",
          },
          {
            label: "统计类型",
            prop: "statistical_type",
            type: 'select',
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=statisticalType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
          },
          {
            label: "主题表",
            prop: "themeTableName",
          },
          {
            label: "检查字段",
            prop: "checkField",
          },
          {
            label: "引用方式",
            prop: "referenceMode",
            type: 'select',
            dicData: [
              {
                label: '字典值',
                value: '1'
              },
              {
                label: '表字段',
                value: '2'
              },
            ],
          },
          {
            label: "字典值",
            prop: "dicBizId",
            type: 'tree',
            props: {
              label: 'title',
              value: 'id'
            },
            display: false,
            dicUrl: '/api/blade-system/dict-biz/tree',
          },
          {
            label: "表字段",
            prop: "tableField",
            formslot: true,
            display: false,
            value: 'default'
          },
          {
            label: "描述",
            prop: "describe",
            type: 'textarea',
            span: 24,
            maxlength: 1000,
            minRows: 3,
            showWordLimit: true
          },

        ]
      },
      specificationTypeDic: [],
    }
  },
  mounted() {
    this.getTreeData();
  },
  watch: {
    model_id: {
      handler(val) {
        if (validatenull(val)) {
          this.query.statistical_type = '';
          this.option.searchBtn = false;
          this.option.emptyBtn = false;
        } else {
          getStatisticalType(val).then(res => {
            this.query.statistical_type = res.data.data;//模型的统计类型
            if (!validatenull(this.query.statistical_type)) {
              this.option.searchBtn = true;
              this.option.emptyBtn = true;
            } else {
              this.option.searchBtn = false;
              this.option.emptyBtn = false;
            }
          })
        }
      }
    }
  },
  methods: {
    setAsException(row) {
      this.$confirm("确定将选择数据设为例外?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return setAsException(JSON.stringify(row));
        })
        .then(() => {
          this.jlOnLoad(this.jlPage);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    viewClose() {
      this.tjDetail = false;
      this.onLoad(this.page);
      this.jlPage = {
        pageSize: 10,
        currentPage: 1,
        total: 0
      }
    },
    view(row) {
      getRuleDetail(row.manage_rule_id).then(res => {
        this.ruleForm = res.data.data;
        this.ruleForm.statistical_type = this.query.statistical_type;
        if (this.ruleForm.type == "STANDARD") {
          getDictionary({code: 'specification_type'}).then(res => {
            this.specificationTypeDic = res.data.data;
          })
          this.viewSpecificationType(this.ruleForm.specificationType);
        } else if (this.ruleForm.type == "QUOTE") {
          this.viewReferenceMode(this.ruleForm.referenceMode);
        }
        let check_column = this.findObject(this.jlOption.column, "check_column");
        let check_column_value = this.findObject(this.jlOption.column, "check_column_value");
        if (this.ruleForm.type == "LOGIC") {
          check_column.hide = true;
          check_column.display = false;
          check_column_value.hide = true;
          check_column_value.display = false;
        } else {
          check_column.hide = false;
          check_column.display = true;
          check_column_value.hide = false;
          check_column_value.display = true;
        }
        this.jlQuery.model_id = this.model_id;
        this.jlQuery.tj_id = row.id;
        this.tjDetail = true;
      })
      //获取规则、jl数据(放在onload)
    },
    viewReferenceMode(val) {
      let dicBizId = this.findObject(this.QUOTE.column, "dicBizId");
      let tableField = this.findObject(this.QUOTE.column, "tableField");
      dicBizId.display = false;
      tableField.display = false;
      if (val == '1') {
        dicBizId.display = true;
      } else if (val == '2') {
        this.ruleForm.tableField = this.ruleForm.datasourceName + '库 ' + this.ruleForm.tableName + '表 ' + this.ruleForm.fieldName + '字段'
        tableField.display = true;
      }
    },
    viewSpecificationType(val) {
      let specificationSubtype = this.findObject(this.STANDARD.column, "specificationSubtype");
      let lengthRange = this.findObject(this.STANDARD.column, "lengthRange");
      let contain = this.findObject(this.STANDARD.column, "contain");
      let regex = this.findObject(this.STANDARD.column, "regex");
      specificationSubtype.display = false;
      lengthRange.display = false;
      contain.display = false;
      regex.display = false;
      if (val == '7') {
        specificationSubtype.display = true;
        getDictionary({code: 'specification_type_date'}).then(res => {
          specificationSubtype.dicData = res.data.data;
        })
      } else if (val == '8') {
        specificationSubtype.display = true;
        getDictionary({code: 'specification_type_time'}).then(res => {
          specificationSubtype.dicData = res.data.data;
        })
      } else if (val == '9') {
        specificationSubtype.display = true;
        getDictionary({code: 'specification_type_datetime'}).then(res => {
          specificationSubtype.dicData = res.data.data;
        })
      } else if (val == '15') {
        //选择长度范围出现2个数字框中间用-连接，只能填正整数或者点击增减数量，用来指定对应字段的长度
        lengthRange.display = true;
      } else if (val == '16') {
        //显示文本框用来填写字符串，文本框后为下拉框，下拉框内容为任意位置、开头、结尾、特定位置，选择特定位置时出现位置（数字框）只能填正整数或者点击增减数量
        contain.display = true;
      } else if (val == '17') {
        //出现文本域可以填写正则表达式，测试字符串文本框填写需要测试的字符串，测试按钮可以针对输入的正则表达式对测试字符串进行正则测试
        regex.display = true;
      }
    },
    changeCycle(val) {
      this.query.current_cycle = val;
    },
    nodeClick(data) {
      if (data.hasChildren) {
        this.query.model_id = data.id;
        this.query.theme_id = '';
      } else {
        this.query.model_id = data.parentId;
        this.query.theme_id = data.id;
      }
      this.model_id = this.query.model_id;
      this.onLoad(this.page)
    },
    getTreeData() {
      getModelThemeTree().then(res => {
        this.treeData = res.data.data;
        this.treeLoading = false
      })
    },
    searchReset() {
      this.query.current_cycle = '';
      // this.data = [];
      if (this.query.statistical_type=='quarter'){
        this.$refs.jd.emptyShowValue();
      }
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = Object.assign({}, this.query, params);
      // this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page)
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page)
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getTJPageList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
    },
    jlOnLoad(page, params = {}) {
      this.jlLoading = true;
      getJLPageList(page.currentPage, page.pageSize, Object.assign(params, this.jlQuery)).then(res => {
        const data = res.data.data;
        this.jlPage.total = data.total;
        this.jlData = data.records;
        this.jlLoading = false;
      });
    },
    jlCurrentChange(currentPage) {
      this.jlPage.currentPage = currentPage;
    },
    jlSizeChange(pageSize) {
      this.jlPage.pageSize = pageSize;
    },
  }
}
</script>

<style scoped>

</style>
